/**
 * Copyright (c) 2015 云智盛世
 * Created with DynamicWordDemo.
 */
package com.hankcs.nlp.lex;

import org.ansj.domain.Term;
import org.ansj.library.UserDefineLibrary;
import org.ansj.splitWord.analysis.ToAnalysis;

import java.util.List;

/**
 * Class description
 *
 * @author GanJc on 2015/9/18
 * 添加动态词典
 */
public class DynamicWordDemo {
    public static void main(String[] args) {
        // 增加新词,中间按照'\t'隔开
        UserDefineLibrary.insertWord("ansj中文分词", "userDefine", 1000);
        List<Term> terms = ToAnalysis.parse("我觉得Ansj中文分词是一个不错的系统!我是王婆!");
        System.out.println("增加新词例子:" + terms);
        // 删除词语,只能删除.用户自定义的词典.
        UserDefineLibrary.removeWord("ansj中文分词");
        terms = ToAnalysis.parse("我觉得ansj中文分词是一个不错的系统!我是王婆!");
        System.out.println("删除用户自定义词典例子:" + terms);
    }
}
